import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const store = () => new Vuex.Store({
    state: {
      nologin:true,
      userinfo:{},
      showlogin:false,
      showrenzheng:false,
      token:"",
      counter: 0,
      routerBack:"",
      secondPage:false,
      secondTitle:"调查问卷",
      breadcrumbs:[
        {name:"首页",url:"/"}
      ]
    },
    mutations: {
      changenshowlogin (state,bu) {
        state.showlogin = bu
      },
      changeBreadcrumbs (state,breadcrumbsdata) {
          if(breadcrumbsdata.type == 0){
            state.breadcrumbs = breadcrumbsdata.data
            window.sessionStorage.breadcrumbs = JSON.stringify(state.breadcrumbs)
          }else if(breadcrumbsdata.type == 1){
            state.breadcrumbs.push(breadcrumbsdata.data)
            window.sessionStorage.breadcrumbs = JSON.stringify(state.breadcrumbs)
          }
          
      },
      changeshowlogin(state,data){
        state.showlogin = data
      },
      breadcrumbspop(state){
        state.breadcrumbs.pop()
      },
      clearBreadcrumbs(state){

      }
    }
  })
  
  export default store